package com.sline.ThreadMethod;

public class Demo6_Yield {
    /*
    * 礼让线程*/
    public static void main(String[] args) {
        new MyThread().start();
        new MyThread().start();
    }
}

class MyThread extends Thread {
    public void run() {
        for (int i = 0; i < 1000; i++) {
            System.out.println(this.getName() + " " + i);
            if (i % 10 == 0) {
                Thread.yield();
            }
        }
    }
}
